package com.fxd.crm.service.impl.gradeImpl;

import com.fxd.crm.mapper.CourseOrderMapper;
import com.fxd.crm.mapper.gradeMapper;
import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.PageResult;
import com.fxd.crm.model.grade;
import com.fxd.crm.service.ICourseOrderService;
import com.fxd.crm.service.IGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther fuxudong
 * @date 2021/3/28 - 18:08
 */
@Service
public class gradeImpl implements IGradeService {

    @Autowired
    gradeMapper orderMapper;


    @Override
    public PageResult<grade> findPageResult(grade grade, int Page, int PageSize) {
        PageResult<grade> result = new PageResult<>();
        result.setCode(0);
        Map<String, Object> params = new HashMap<>();
        params.put("condition",grade);
        params.put("start",(Page-1)*PageSize);
        params.put("pageSize",PageSize);
        int count = orderMapper.findCountByMap(params);
        result.setCount(count);
        //获取查询的数据
        List<grade> list = orderMapper.findListByMap(params);
        result.setData(list);
        return result;
    }



    @Override
    public void save(grade grade) {
        orderMapper.insert(grade);
    }

    @Override
    public grade findByOrderId(Map<String,String> map) {
        grade grade = orderMapper.findByOrderId(map);
        return grade;
    }

    @Override
    public void deleteByOrderId(grade grade) {
        orderMapper.deleteByOrderId(grade);
    }

    @Override
    public void update(grade grade) {
        orderMapper.update(grade);
    }
}
